package com.youlu.campus.admin.commission.controller;

import com.youlu.campus.admin.utils.AuthUtils;
import com.youlu.campus.entity.commission.dto.DistributorAccountWithdrawOperationDTO;
import com.youlu.campus.entity.commission.dto.DistributorAccountWithdrawSearchDTO;
import com.youlu.campus.service.commission.DistributorAccountService;
import com.yuelin.infrastructure.quantum.common.QResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : [dengbo]
 * @className : DistributorWithdrawAdminController
 * @description : [分账提现后台]
 * @createTime : [2023/2/6 14:39]
 */
@Slf4j
@RestController
@RequestMapping("/distributor")
public class DistributorWithdrawAdminController {
    @Autowired
    private DistributorAccountService distributorAccountService;

    /**
     * 后台提现列表
     *
     * @param query
     * @return
     */
    @PostMapping("/withdraw/list")
    public QResult save(@RequestBody @Validated DistributorAccountWithdrawSearchDTO query) {
        return QResult.success(distributorAccountService.getAdminWithdrawList(query));
    }

    /**
     * 提现操作
     *
     * @param query
     * @return
     */
    @PostMapping("/withdraw/operation")
    public QResult save(@RequestBody @Validated DistributorAccountWithdrawOperationDTO query) {
        String username = AuthUtils.getLoginName();
        query.setOperator(username);
        return QResult.success(distributorAccountService.adminAdminWithdrawOperation(query));
    }
}
